package com.youmeek.demo.web.servlet.service.Impl;

import com.youmeek.demo.web.servlet.pojo.User;
import com.youmeek.demo.web.servlet.service.UserService;

import java.util.ArrayList;
import java.util.List;

public class UserServiceImpl implements UserService {

    private UserServiceImpl(){ }
    private static final UserServiceImpl USER_SERVICE = new UserServiceImpl();
    public static UserServiceImpl getInstance(){
        return USER_SERVICE;
    }

        @Override
        public boolean loginUser(String userName, String passWord) throws Exception{
            boolean flag = false;
            if ("".equals(userName) || null == userName){
                throw new Exception("用户名不能为空");
            }
            if ("".equals(passWord) || null == passWord){
                throw new Exception("密码不能为空");
            }
            if (userName.equalsIgnoreCase("admin") && passWord.equalsIgnoreCase("123")){
                flag = true;
            }
            return flag;
        }

    @Override
    public List<User> getUser() {
        User user = new User();
        user.setUserName("张三");
        user.setPassWord("111");
        List<User> userList = new ArrayList<>();
        userList.add(user);
        return userList;
    }
}
